Transform a function (typically used in sort_by), so that its ouput can be sorted in descending order.

descending(f)

Arguments

f

a function to modify.

Value

A function returning a numeric vector which, if passed to order, will be used to sort some data.

Examples

desc_abs <- descending(abs) x <- -2:1 order(abs(x))
#> [1] 3 2 4 1
order(desc_abs(x))
#> [1] 1 2 4 3